﻿using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OAuthClient.Models;
//using OAuthClient.Server;
using System.Diagnostics;
using System.Security.Claims;

namespace OAuthClient.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

        public IActionResult Index()
        {
            return View();
        }

        [Authorize]
        public IActionResult Privacy()
        {
        var claims=    HttpContext.User.Claims.ToList();

            ViewBag.claims = claims;
            return View();
        }

        //[HttpGet("auth/callback")]
        //public IActionResult callback(string code)
        //{
           
        //    return View();
        //}
        //public async Task<IActionResult> info(AuthClient client)
        //{
        //    var name = HttpContext.User.FindFirstValue("name");
        //  string info=await  client.GetInfo(name);
        //    ViewBag.info = info;
        //    return View();
        //}
        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
